package com.mytools.common.pattern.itreator02;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author LJK
 * @description
 * @date 2025/2/10
 */
public class main {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        enhanceFor(list);
    }
    //正常使用的增强for方法
    public static void enhanceFor(ArrayList<String> list){
        for (String s : list) {
            System.out.println(s);
        }
    }

    //根据Iterator方法实际的for方法
    public static void iteratorFor(ArrayList<String> list){
        Iterator<String>iterator= list.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            System.out.println(next);
        }
    }
}
